<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>图书详情 - 图书管理系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
</head>
<body>
<nav th:replace="fragments/navbar :: navbar"></nav>

<div class="container mt-4">
    <div class="row mb-4">
        <div class="col-md-6">
            <h2>图书详情</h2>
        </div>
        <div class="col-md-6 text-right">
            <a href="/books" class="btn btn-secondary">返回列表</a>
        </div>
    </div>

    <div class="card">
        <div class="card-body">
            <div class="row">
                <div class="col-md-12">
                    <h3 th:text="${book.title}" class="mb-3"></h3>
                    <p><strong>作者：</strong><span th:text="${book.author}"></span></p>
                    <p><strong>ISBN：</strong><span th:text="${book.isbn} ?: '无'"></span></p>
                    <p><strong>出版社：</strong><span th:text="${book.publisher} ?: '无'"></span></p>
                    <p><strong>出版年份：</strong><span th:text="${book.publicationYear} ?: '无'"></span></p>
                    <p><strong>库存数量：</strong>
                        <span th:text="${book.stock}" class="badge"
                              th:classappend="${book.stock > 0 ? 'badge-success' : 'badge-danger'}">
                            </span>
                    </p>
                    <p><strong>图书描述：</strong></p>
                    <p th:text="${book.description} ?: '无描述'" class="text-justify"></p>
                    <p><strong>创建时间：</strong><span th:text="${#temporals.format(book.createTime, 'yyyy-MM-dd HH:mm:ss')}"></span></p>
                    <p><strong>最后更新：</strong><span th:text="${#temporals.format(book.updateTime, 'yyyy-MM-dd HH:mm:ss')}"></span></p>
                </div>
            </div>
            <div class="mt-4 text-right">
                <a th:href="@{/books/edit/{id}(id=${book.id})}" class="btn btn-warning mr-2">编辑</a>
                <a th:href="@{/books/delete/{id}(id=${book.id})}" class="btn btn-danger"
                   onclick="return confirm('确定要删除这本书吗？')">删除</a>
            </div>
        </div>
    </div>
</div>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>